/*
 * Copyright (C) 2012 Le Tuan Anh <anh.takaji@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ezcms.dal.client;

import ezcms.dal.AbstractDAOFactory;
import ezcms.dal.ConferenceDAO;
import ezcms.dal.ConferenceItemDAO;
import ezcms.dal.DAOFactory;
import ezcms.dal.ResourceDAO;
import ezcms.dal.RoleDAO;
import ezcms.dal.SubmissionDAO;
import ezcms.dal.UserDAO;

/**
 *
 * @author Le Tuan Anh <anh.takaji@gmail.com>
 */
public class DAOUtil {

    private DAOFactory factory;
    private UserDAO userDAO;
    private RoleDAO roleDAO;
    private ResourceDAO resourceDAO;
    private ConferenceDAO conferenceDAO;
    private SubmissionDAO submissionDAO;
    private ConferenceItemDAO conferenceItemDAO;

    public DAOUtil() {
        factory = AbstractDAOFactory.getDAOFactory(AbstractDAOFactory.HIBERNATE_MYSQL, null);
    }

    public DAOFactory getFactory() {
        if (factory == null) {
            factory = AbstractDAOFactory.getDAOFactory(AbstractDAOFactory.HIBERNATE_MYSQL, null);
        }
        return factory;
    }

    public ResourceDAO getResourceDAO() {
        if (resourceDAO == null) {
            resourceDAO = factory.getResourceDAO();
        }
        return resourceDAO;
    }

    public RoleDAO getRoleDAO() {
        if (roleDAO == null) {
            roleDAO = factory.getRoleDAO();
        }
        return roleDAO;
    }

    public UserDAO getUserDAO() {
        if (userDAO == null) {
            userDAO = factory.getUserDAO();
        }
        return userDAO;
    }

    public ConferenceDAO getConferenceDAO() {
        if (conferenceDAO == null) {
            conferenceDAO = factory.getConferenceDAO();
        }
        return conferenceDAO;
    }

    public SubmissionDAO getSubmissionDAO() {
        if (submissionDAO == null) {
            submissionDAO = factory.getSubmissionDAO();
        }
        return submissionDAO;
    }

    public ConferenceItemDAO getConferenceItemDAO() {
        if (conferenceItemDAO == null) {
            conferenceItemDAO = factory.getConferenceItemDAO();
        }
        return conferenceItemDAO;
    }
}
